package com.hnucm.c202001090145.controller;

import com.hnucm.c202001090145.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class StudentController {
    @Autowired
    StudentService studentService;
    @RequestMapping("studentlist")
    public String StudentList(Model model){
        model.addAttribute("studentlist",studentService.findAllStuAndCourse());
        return "studentlist.html";
    }
    @RequestMapping("deletestudentbyid")
    public String deleteCourse(String num){
        studentService.deleteStudentByNum(num);
        return "redirect:/studentlist";
    }

    @RequestMapping("lookinfo")
    public String courseList(Model model, String name){
        model.addAttribute("courseList",studentService.findCourseByName(name));
        model.addAttribute("name",name);
        return "courseList.html";
    }
}
